/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.Interactions.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import uimigration.Interactions.Content;
import uimigration.Interactions.InteractionsPackage;
import uimigration.Interactions.SelectContent;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Select Content</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.Interactions.impl.SelectContentImpl#getCardinality <em>Cardinality</em>}</li>
 *   <li>{@link uimigration.Interactions.impl.SelectContentImpl#getSelectableContent <em>Selectable Content</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SelectContentImpl extends BehaviourImpl implements SelectContent {
	/**
	 * The cached value of the '{@link #getCardinality() <em>Cardinality</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCardinality()
	 * @generated NOT
	 * @ordered
	 */
	protected EList<Integer> cardinality;

	/**
	 * The cached value of the '{@link #getSelectableContent() <em>Selectable Content</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSelectableContent()
	 * @generated
	 * @ordered
	 */
	protected EList<Content> selectableContent;
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SelectContentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return InteractionsPackage.Literals.SELECT_CONTENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public EList<Integer> getCardinality() {
		if (cardinality == null) {
			cardinality = new EDataTypeUniqueEList<Integer>(Integer.class, this,
					InteractionsPackage.SELECT_CONTENT__CARDINALITY);
		}
		return cardinality;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	@SuppressWarnings("unchecked")
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case InteractionsPackage.SELECT_CONTENT__CARDINALITY:
			getCardinality().clear();
			getCardinality().addAll((Collection<Integer>) newValue);
			return;
		case InteractionsPackage.SELECT_CONTENT__SELECTABLE_CONTENT:
			getSelectableContent().clear();
			getSelectableContent().addAll((Collection<Content>) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case InteractionsPackage.SELECT_CONTENT__CARDINALITY:
				getCardinality().clear();
				return;
			case InteractionsPackage.SELECT_CONTENT__SELECTABLE_CONTENT:
				getSelectableContent().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case InteractionsPackage.SELECT_CONTENT__CARDINALITY:
				return cardinality != null && !cardinality.isEmpty();
			case InteractionsPackage.SELECT_CONTENT__SELECTABLE_CONTENT:
				return selectableContent != null && !selectableContent.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (cardinality: ");
		result.append(cardinality);
		result.append(')');
		return result.toString();
	}

	@Override
	public EList<Integer> getCardinalityList() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public EList<Content> getSelectableContent() {
		if (selectableContent == null) {
			selectableContent = new EObjectContainmentEList<Content>(Content.class, this,
					InteractionsPackage.SELECT_CONTENT__SELECTABLE_CONTENT);
		}
		return selectableContent;
	}

	@Override
	public EList<Content> getSelectableContentList() {
		if (selectableContent == null) {
			selectableContent = new EObjectContainmentEList<Content>(Content.class, this,
					InteractionsPackage.SELECT_CONTENT__SELECTABLE_CONTENT);
		}
		return selectableContent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
			case InteractionsPackage.SELECT_CONTENT__SELECTABLE_CONTENT:
				return ((InternalEList<?>)getSelectableContent()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case InteractionsPackage.SELECT_CONTENT__CARDINALITY:
				return getCardinality();
			case InteractionsPackage.SELECT_CONTENT__SELECTABLE_CONTENT:
				return getSelectableContent();
		}
		return super.eGet(featureID, resolve, coreType);
	}

} //SelectContentImpl
